import { createRouter, createWebHistory } from 'vue-router';
import layout from '@/layout/index.vue';
const constantRoutes:any = [
  {
    path: '/login',
    name: 'login',
    component: ()=> import('@/views/login/index.vue')
  },
  {
    path: '/404',
    name: '404',
    component: ()=> import('@/views/errorPage/404.vue')
  },
  {
    path: '/403',
    name: '403',
    component: ()=> import('@/views/errorPage/403.vue')
  }
]

/**
 * 根据用户权限不同，所能看到得页面和操作性也不同
 */
export const asyncRouter:any =  [
  {
    path: '/',
    redirect: '/user',
    hidden: true
  },
  {
    path: '/user',
    name: 'user',
    component: layout,
    redirect: '/user/index',
    children: [
      {
        path: 'index',
        meta: { title: '用户管理' , icon: 's-custom' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/user/index.vue'),
      }
    ]
  },
  {
    path: '/banner',
    name: 'banner',
    component: layout,
    meta: { title: 'banner图管理', icon: 's-marketing' },
    children: [
      {
        path: 'index',
        meta: { title: 'banner图管理', icon: 'picture' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "banner资讯" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      }
    ]
  },
  {
    path: '/skin',
    name: 'skin',
    component: layout,
    children: [
      {
        path: 'index',
        meta: { title: '皮肤管理', icon: 's-custom' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue')
      }
    ]
  },
  {
    path: '/snatch',
    name: 'snatch',
    component: layout,
    meta: { title: "夺宝管理", icon: 'platform-eleme'},
    children: [
      {
        path: 'draws',
        meta: { title: "夺宝活动配置" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "夺宝贡献排名管理" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "往期夺宝贡献排名" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      }
    ]
  },
  {
    path: '/skinGroup',
    name: 'skinGroup',
    component: layout,
    children: [
      {
        path: 'index',
        meta: { title: '皮肤组管理', icon: 'platform-eleme' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue')
      }
    ]
  },
  {
    path: '/competition',
    name: 'competition',
    component: layout,
    meta: { title: '赛事管理', icon: 'platform-eleme' },
    children: [
      {
        path: 'draws',
        meta: { title: "赛事分享" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "赛事数据列表" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "比赛信息列表" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "战队列表" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      }
    ]
  },
  {
    path: '/invite',
    name: 'competition',
    component: layout,
    children: [
      {
        path: 'index',
        meta: { title: '邀新分享管理', icon: 'platform-eleme' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue')
      }
    ]
  },
  {
    path: '/bindBox',
    name: 'bindBox',
    component: layout,
    children: [
      {
        path: 'index',
        meta: { title: '皮肤盲盒管理', icon: 'platform-eleme' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue')
      }
    ]
  },
  {
    path: '/exchange',
    name: 'exchange',
    component: layout,
    meta: { title: '兑换记录管理', icon: 'platform-eleme' },
    children: [
      {
        path: 'draws',
        meta: { title: "兑换订单" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "赠送记录" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      }]
  },
  {
    path: '/goodsLog',
    name: 'goodsLog',
    component: layout,
    children: [
      {
        path: 'index',
        meta: { title: '补物品日志', icon: 'platform-eleme' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/goodsLog/index.vue')
      }
    ]
  },
  {
    path: '/recordUser',
    name: 'recordUser',
    component: layout,
    meta: { title: '用户记录', icon: 'platform-eleme' },
    children: [
      {
        path: 'draws',
        meta: { title: "购买记录" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "抽卡记录" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      },
      {
        path: 'draws2',
        meta: { title: "重置记录" },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue'),
      }
    ]
  },
  {
    path: '/admin',
    name: 'admin',
    isAdmin: true,
    component: layout,
    children: [
      {
        path: 'index',
        meta: { title: '后台配置', icon: 'platform-eleme' },
        component: () => import(/* webpackChunkName: "about" */ '@/views/snatch/index.vue')
      }
    ]
  },
  { path: '/:catchAll(.*)', redirect: '/404', hidden: true }
]

const router = createRouter({
  history: createWebHistory(),
  routes: constantRoutes,
  linkActiveClass: 'active'
})

export default router
